import httpFetch from 'share/httpFetch';
import errorMessage from 'share/errorMessage';

export default {
  // 查询发票可抵扣
  getDeductibleConfig() {
    return httpFetch.get(`/api/receipt/deductible/config`)
      .catch(e => {
        errorMessage(e.response);
        throw e;
      });
  },
  // 查询费用价税分离规则
  getSeparationConfig(params) {
    return httpFetch.get(`/api/receipt/separation/invoice/config`, params)
      .catch(e => {
        errorMessage(e.response);
        throw e;
      });
  },
  // 修改发票可抵扣
  setDeductibleConfig(params) {
    return httpFetch.post(`/api/receipt/deductible/config`, params)
      .catch(e => {
        errorMessage(e.response);
        throw e;
      });
  },
  // 查询费用价税分离规则
  setSeparationConfig(params) {
    return httpFetch.post(`/api/receipt/separation/invoice/config`, params)
      .catch(e => {
        errorMessage(e.response);
        throw e;
      });
  },
  // 删除费用价税分离规则
  deletePriceTax(id) {
    return httpFetch.delete(`/api/receipt/separation/invoice/config/${id}`)
      .catch(e => {
        errorMessage(e.response);
        throw new Error('delete error');
      });
  },
  // 查询费用价税分离规则详情
  getSeparationdetails(separationInvoiceOptId) {
    return httpFetch.get(`/api/receipt/separation/invoice/config/${separationInvoiceOptId}`, )
      .catch(e => {
        errorMessage(e.response);
        throw e;
      });
  },
  //获取当前最高优先级
  highestPriority(){
    return httpFetch.get(`/api/receipt/separation/invoice/config/highestPriority`)
      .catch(e => {
        errorMessage(e.response);
        throw new Error('get error');
      });
  }

};
